<!DOCTYPE html>
<html>
<head>
    <title>机房状态监控</title>
    <style>
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            margin: 30px;
            background-color: #f5f7fa;
            color: #333;
        }
        h1 {
            color: #2c3e50;
            font-size: 36px;
            margin-bottom: 25px;
            font-weight: 600;
            text-align: center;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
        }
        .status-legend {
            margin: 30px auto;
            padding: 20px;
            background: white;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.05);
            max-width: 800px;
            font-size: 20px;
        }
        .status-legend strong {
            font-size: 22px;
            color: #34495e;
        }
        .status-legend span {
            display: inline-block;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            margin: 0 10px 0 25px;
            vertical-align: middle;
            box-shadow: 0 2px 4px rgba(0,0,0,0.2);
        }
        .count-display {
            margin-top: 15px;
            font-size: 22px;
            padding: 12px;
            background: #f8f9fa;
            border-radius: 6px;
            text-align: center;
        }
        .count-display strong {
            color: #2980b9;
            font-size: 24px;
        }
        .image-container {
            margin: 40px auto;
            text-align: center;
            overflow: hidden;
            position: relative;
            max-width: 1200px;
            border-radius: 8px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.1);
            background: white;
            padding: 20px;
        }
        .zoom-controls {
            position: absolute;
            top: 20px;
            right: 20px;
            z-index: 100;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        .zoom-btn {
            width: 40px;
            height: 40px;
            background: rgba(52, 152, 219, 0.8);
            color: white;
            border: none;
            border-radius: 50%;
            cursor: pointer;
            font-size: 22px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
            box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        }
        .zoom-btn:hover {
            background: #3498db;
            transform: scale(1.1);
        }
        #rack-image {
            max-width: 100%;
            height: auto;
            border: 1px solid #e0e0e0;
            border-radius: 4px;
            transition: transform 0.3s ease;
        }
    </style>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
    <h1>数据中心实时状态监控</h1>
    <div class="status-legend">
        <strong>设备状态标识：</strong>
        <span style="background:#4CAF50; box-shadow: 0 0 5px #4CAF50"></span>已租用
        <span style="background:#F44336; box-shadow: 0 0 5px #F44336"></span>可租用
        <div class="count-display">
            当前可用机柜数量: <strong>{{ count }}</strong>
        </div>
    </div>
    
    <div class="image-container">
        <div class="zoom-controls">
            <button class="zoom-btn" id="zoom-in" title="放大">+</button>
            <button class="zoom-btn" id="zoom-out" title="缩小">-</button>
            <button class="zoom-btn" id="zoom-reset" title="重置">↻</button>
        </div>
        {% load static %}
        <img id="rack-image" src="{% static 'idc/rack_status.png' %}" alt="机架状态图">
    </div>

    <script>
        $(document).ready(function() {
            let scale = 1;
            const image = $('#rack-image');
            
            $('#zoom-in').click(function() {
                scale += 0.1;
                image.css('transform', `scale(${scale})`);
            });
            
            $('#zoom-out').click(function() {
                if(scale > 0.2) {
                    scale -= 0.1;
                    image.css('transform', `scale(${scale})`);
                }
            });
            
            $('#zoom-reset').click(function() {
                scale = 1;
                image.css('transform', 'scale(1)');
            });
            
            // 添加鼠标滚轮缩放
            $('.image-container').on('wheel', function(e) {
                e.preventDefault();
                if(e.originalEvent.deltaY < 0) {
                    scale = Math.min(scale + 0.1, 3); // 限制最大缩放为3倍
                } else {
                    scale = Math.max(scale - 0.1, 0.2); // 限制最小缩放为0.2倍
                }
                image.css('transform', `scale(${scale})`);
            });
        });
    </script>
</body>
</html>
